import { MethodType,request,POST } from "./http";
import MYURL from './config'

export const _goodsList = async (page,keyword,catId,onSale)=>{
  return await request('/api/admin/goods/list', MethodType.GET, {
    page,
    keyword,
    catId,
    onSale,
  })
};

export const _getArticleData=async(index) =>{
  try{
    let res = await request(MYURL.article,MethodType.GET,{index},{isCancleToken:true})
    return await Promise.resolve(res)
  }
  catch(err){
    return await Promise.resolve(err)
  }
}

export const _getTopicData =async() =>{
  try{
    let res = await request(MYURL.topice,MethodType.GET,{},{isCancleToken:true})
    return await Promise.resolve(res)
  }
  catch(err){
    return await Promise.resolve(err)
  }
};

export const _getAuthorData =async () =>{
  try{
    let res = await request(MYURL.authorList,MethodType.GET,{},{isCancelTocken:true})
    return await Promise.resolve(res)
  }
  catch(err){
    return await Promise.resolve(err)
  }
}
export const _getLunBoData =async (pagenum,index)=>{
   try{
    let res =  await request(MYURL.lunboImage, MethodType.GET,{pagenum,index},{isCancelTocken:true})
    return await Promise.resolve(res);
   }
   catch(err){
    return await Promise.resolve(err)
   } 
};

export const _isLogin =async(params)=>{
  try{
    let res =  await request(MYURL.login, MethodType.GET, params,{isCancelTocken:true})
    // let res =  await request(URL.login, MethodType.POST, params,{isCancelTocken:true})
    return await Promise.resolve(res);
  }
  catch(err){
   return  await Promise.resolve(err)
  } 
};